<?php

class BuildChannelTask extends sfBaseTask
{
  protected function configure()
  {
    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'),
    ));

    $this->aliases          = array( 'build-channel' );
    $this->namespace        = 'pirum';
    $this->name             = 'build-channel';
    $this->briefDescription = 'Builds the PEAR channel.';
    $this->detailedDescription = <<<EOF
The [BuildChannel|INFO] task builds the PEAR channel of the application thanks to pirum library.
Call it with:

  [php symfony pirum:build-channel|INFO]
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
    // initialize the database connection
    $databaseManager = new sfDatabaseManager($this->configuration);
    $connection = $databaseManager->getDatabase($options['connection'])->getConnection();

    $this->logSection('START', date('d-m-Y H:i:s') );
    $this->logSection('END', date('d-m-Y H:i:s') );
  }
}
